import type { Api_Response_Dto } from '@/dto/response/Api_Response_Dto';
import request from '@/utils/request'
const BASE_URL = 'http://localhost:5293/api/products';

interface Api_Response_Dto {
    code: number;
    message: string;
    data?: any;
}

/**
 * 获取产品类别列表
 * @param obj
 * @returns
 */
export const get_products_types = (obj:{key:string}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Get_Products_Types",
        method: "get",
        params:obj
    });
}
/**
 * 新增产品类别列表
 * @param obj
 * @returns
 */
export const add_products_types = (obj: { name: string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Add_Products_Types",
        method: "post",
        params: obj
    });
}

/**
 * 获取产品类别下的产品
 * @param obj
 * @returns
 */
export const details_products = (obj: { id: string,key:string}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Details_Products",
        method: "get",
        params: obj
    });
}
/**
 * 更新产品信息
 * @param obj
 * @returns
 */
export const update_Product = (obj: { id: string, name: string, price: number, expalain: string,enddatetime:Date,img:string,startdatetime:Date,discountprice:number }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Update_Product",
        method: "post",
        data: obj
    });
}
/**
 * 更新产品类型信息
 * @param obj
 * @returns
 */
export const update_Product_Type = (obj: { id: string, name: string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Update_Product_Type",
        method: "post",
        params: obj
    });
}

/**
 * 删除产品
 * @param obj
 * @returns
 */
export const delete_Product = (obj: { id: string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Delete_Product",
        method: "post",
        params: obj
    });
}
/**
 * 删除产品类别
 * @param obj
 * @returns
 */
export const delete_Product_type = (obj: { id: string }):
Promise<Api_Response_Dto> => {
return request({
    url: "api/products/Delete_Product_Type",
    method: "post",
    params: obj
});
}

/**
 * 新增产品
 * @param obj
 * @returns
 */
export const add_product = (obj: { name: string, price: number, expalain: string,enddatetime?:Date,img:string,startdatetime?:Date,discountprice:number,typeid:string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Add_product",
        method: "post",
        data: obj
    });
}


/**
 * 获取产品
 * @param obj
 * @returns
 */
export const get_products = (obj: { key: string;page:number,limit:number }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Get_Products",
        method: "get",
        params: obj
    });
}
/**
 * 获取产品类型
 * @param obj
 * @returns
 */
export const get_products_types_products = ():
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Get_Products_Types_Products",
        method: "get",
    });
}
/**
 * 上架产品
 * @param obj
 * @returns
 */
export const update_List = (obj: { id: string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Update_List",
        method: "post",
        params: obj
    });
}
/**
 * 获取单个产品
 * @param obj
 * @returns
 */
export const Details_Products_single = (obj: { id: string }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Details_Products_single",
        method: "get",
        params: obj
    });
}
/**
 * 新增套餐
 * @param obj
 * @returns
 */
export const Add_Setmenu = (obj: Array<{id:string, sum:number,img:string, money:number}>,obj2:{name:string,list:number}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Add_Setmenu",
        method: "post",
        data: obj,
        params:obj2
    });
}
/**
 * 查看所有套餐
 * @param obj
 * @returns
 */
export const Get_Setmenu = (obj: { key: string;page:number,limit:number }):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Get_Setmenu",
        method: "get",
        params:obj
    });
}
/**
 * 修改套餐和其下的产品
 * @param obj
 * @returns
 */
export const Update_Setmenu = (obj:Array<{id:string,sum:number,img:string, money:number}>,obj2:{id:string,name:string,list:number}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Update_Setmenu",
        method: "post",
        data:obj,
        params:obj2
    });
}

/**
 * 获取套餐下的产品
 * @param obj
 * @returns
 */
export const Get_Setmenu_product = (obj:{id:string}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Get_Setmenu_product",
        method: "get",
        params:obj
    });
}
/**
 * 删除套餐
 * @param obj
 * @returns
 */
export const Del_Setmenu = (obj:{id:string}):
    Promise<Api_Response_Dto> => {
    return request({
        url: "api/products/Del_Setmenu",
        method: "post",
        params:obj
    });
}
